package com.huishao.api;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 启动类
 *
 * @author huishao
 * @since 2022-12-29 15:29:28
 */
@SpringBootApplication
@MapperScan("com.huishao.api.mapper")
@Slf4j
public class ApiApplication {
    public static void main(String[] args) throws UnknownHostException {
        Environment env = SpringApplication.run(ApiApplication.class, args).getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        path = path != null ? "/" + path : "";

        log.info("项目启动成功...");
        log.info("==========首次使用,请先修改配置文件中的数据源信息==========");
        log.info("接口文档访问地址：http://{}:{}{}/doc.html", ip, port, path);

        // 启动加载指定页面
        try {
            Runtime.getRuntime().exec("cmd   /c   start   " + "http://" + ip + ":" + port + "/index.html");//可以指定自己的路径
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        try {
            Runtime.getRuntime().exec("cmd   /c   start   " + "http://" + ip + ":" + port + "/doc.html");//可以指定自己的路径
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

